package general;

public class SM_Mult extends Functional_Unit {

    //
    //default constructor
    //
    public SM_Mult () {
        super();
    }
    
    //
    //regular constructor
    //
    public SM_Mult (int new_m, int new_dim) {
        //create a functional unit
        super(new_m, new_dim);
    }
    
    //
    //carry out a multiplication
    //
    public void multiply(int inA, int inB) {
        layout();
        initialize( inA, inB );
        //take the two's complement of the MSBs of the operands
        compute();
    }

    //
    //establish the cell layout
    //
    @Override
    public void layout() {
        int i, j;
        
        //set the cell types
        //configure the first row  
        //upper left cell is of type B
        cellfield[0][0].setType('B');
        //the rest of the row is of type A
        for(i = 1; i < getDim(); i++) {
            cellfield[0][i].setType('A');
        }

        //configure the inner rows
        //iterate through the innerrows
        for(i = 1; i < getDim() - 1; i++) {     
            cellfield[i][0].setType('D');
            //iterate over the row entries
            for(j = 1; j < getDim(); j++) {   
                if(j == i) {
                    //diagonal positions are of type C
                    cellfield[i][j].setType('C');   
                }
                else {
                    //all others are of type A
                    cellfield[i][j].setType('A');   
                }
            }
        }

        //configure the last row
        //the lower left corner is of type H
        cellfield[getDim() - 1][0].setType('H');
        //the lower right corner is of type E
        cellfield[getDim() - 1][getDim() - 1].setType('E');
        //all other are of type F
        for(i = 1; i < getDim() - 1; i++) {
            //set cell type
            cellfield[getDim() - 1][i].setType('F');
        }
    }
    
    //
    //perform the multiplication
    //
    @Override
    public int compute() {
        return 0;
    }

}

